//
//  NNRCNetRequest.m
//  nncloud
//
//  Created by macfai on 2018/10/24.
//  Copyright © 2018年 youedata. All rights reserved.
//

#import "NNRCNetRequest.h"

@implementation NNRCNetRequest

#pragma mark  重写父类
+ (instancetype)manager{
    
    NNRCNetRequest *instanse=[[NNRCNetRequest alloc]initWithRequestSerialization:[RCHttpRequestSerialization serializer] responseSerialization:[RCJSONResponseSerialization serializer]];
    instanse.isAllowHttps=YES;
    return instanse;
    
}

-(instancetype)initWithRequestSerialization:(id<RCURLRequestSerialization>)aReqSerialization responseSerialization:(id<RCURLResponseSerialization>)aRepSerializaiton{
    self = [super init];
    if (self) {
        
        [self setupRequestSerialization:aReqSerialization responseSerialization:aRepSerializaiton];
        
    }
    return self;
}
- (void)setupRequestSerialization:(id<RCURLRequestSerialization>)aReqSerialization responseSerialization:(id<RCURLResponseSerialization>)aRepSerializaiton{
    self.requestSerialization=aReqSerialization;
    self.responseSerialization=aRepSerializaiton;
}
- (id)postWithUrl:(NSString *)url params:(id)params success:(RCNetRequestSuccessBlock)aSuccess failure:(RCNetRequestFailureBlock)aFailure{
    NSLog(@"post url %@",params);
    url = [NSString stringWithFormat:@"%@%@",HOST,url];
    AFHTTPSessionManager *manager=[super postWithUrl:url params:params success:aSuccess failure:aFailure];
    return manager;
}
- (id)getWithUrl:(NSString *)url params:(id)params success:(RCNetRequestSuccessBlock)aSuccess failure:(RCNetRequestFailureBlock)aFailure{
    NSLog(@"get url %@",params);
    url = [NSString stringWithFormat:@"%@%@",HOST,url];
    NSURLSessionTask *manager=[super getWithUrl:url params:params success:aSuccess failure:aFailure];
    return manager;
}


#pragma mark - 新添加的方法


+(NSInteger)getStatusCodeWithObj:(NSDictionary *)dic{
    NSString *code = dic[@"code"];
    return [code integerValue];
}

@end
